package DiErZhou.Day1;

import java.util.Random;
import java.util.Scanner;

public class Day1_7 {
    public static void main(String[] args) {
        Random random = new Random();
        int guessnum = random.nextInt(10) + 1;
        int flag = 0;
        for (flag = 0; flag < 3; flag++) {
            System.out.println("请输入一个你猜想的数字");
            Scanner scanner = new Scanner(System.in);
            int usernum = scanner.nextInt();
            if (usernum < guessnum) {
                System.out.println("你猜小啦！");
            } else if (usernum > guessnum) {
                System.out.println("你猜大啦！");
            } else if (usernum == guessnum) {
                System.out.println("你猜对了！！！");
                break;
            }

            if (3 - flag-1 > 0) {
                System.out.println("你还剩" + (3 - flag - 1) + "次机会");

            } else {
                System.out.println("你的机会用完了！");
            }
        }

    }
}